home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / utilitys / bytes110 / part01
Encoding:
Internet Message Format  |  1991-03-14  |  5.2 KB

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i059: Bytes 1.10 - display number of free bytes on selected drive, Part01/01
  4. Reply-To: d0pbm@dtek.chalmers.se (Per Bergehed)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i059@ab20.larc.nasa.gov>
  7. Date: 14 Mar 91 01:17:25 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga.misc
  11.  
  12. Submitted-by: d0pbm@dtek.chalmers.se (Per Bergehed)
  13. Posting-number: Volume 91, Issue 059
  14. Archive-name: utilities/bytes-1.10/part01
  15.  
  16.    This program will display the number of free bytes on selected drive:
  17.  
  18.    Syntax: Bytes [DRIVE:] 
  19.  
  20.  
  21. #!/bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 1 (of 1)."
  28. # Contents:  bytes.c
  29. # Wrapped by tadguy@ab20 on Wed Mar 13 20:17:23 1991
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'bytes.c' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'bytes.c'\"
  33. else
  34. echo shar: Extracting \"'bytes.c'\" \(3040 characters\)
  35. sed "s/^X//" >'bytes.c' <<'END_OF_FILE'
  36. X/*-------------------------------------------------------------------------*/
  37. X/* Bytes v1.10 Released to the Public Domain 1991.01.04 /PBM/ Per Bergehed */
  38. X/*-------------------------------------------------------------------------*/
  39. X/* s-nail: Per Bergehed            *  This code is not a "good" example of */
  40. X/*         Richertsgatan 2C/3003   *  C Programming, but hopefully there   */
  41. X/*         412 81 Gothenburg       *  is something usable !?               */
  42. X/*         SWEDEN                  *  There shouldn't be any problems if   */
  43. X/* e-mail: d0pbm@dtek.chalmers.se  *  you want to modify it to not use ARP */
  44. X/*-------------------------------------------------------------------------*/
  45. X/*
  46. X   This program will display the number of free bytes on selected drive:
  47. X
  48. X   Syntax: Bytes [DRIVE:] 
  49. X*/
  50. X/*-------------------------------------------------------------------------*/
  51. X/* 
  52. X   I compiled this source with Lattice C as follows:
  53. X
  54. X   LC -v Bytes.c
  55. X   BLINK LIB:arpc.o RAM:bytes.o TO RAM:Bytes LIB lib:arp.lib,lib:amiga.lib,lib:lc.lib SD SC ND 
  56. X
  57. X*/
  58. X/*-------------------------------------------------------------------------*/
  59. X
  60. X#include <exec/types.h>
  61. X#include <stdlib.h>
  62. X#include <string.h>
  63. X#include <dos.h>
  64. X#include <libraries/arpbase.h>
  65. X#include <libraries/arp_pragmas.h>
  66. X#include <arpfunctions.h>
  67. X
  68. X
  69. X
  70. X#define  Kb                 1024L
  71. X#define  Mb                (Kb*Kb)
  72. X
  73. X
  74. X
  75. Xchkabort (void) {}                  /* dummy to get rid of chkabort() */
  76. X
  77. X
  78. X
  79. Xstruct DISKINFO info;
  80. X
  81. X
  82. X
  83. Xvoid _main(argv)
  84. Xregister char *argv;
  85. X{
  86. X register char MyPath[255];
  87. X register char *myptr = MyPath;
  88. X
  89. X  while (*argv != ' ')
  90. X   argv++;
  91. X  while (*argv == ' ')
  92. X   argv++;                     /* argv now points to command line argument */
  93. X
  94. X  if ( *argv == '\x0a' )           /* no argument -> get current directory */
  95. X    {
  96. X     if (getcd(0,MyPath)) goto error;     /* getcd() - AMIGA function */
  97. X    }
  98. X  else                                            /* get argument */
  99. X    {
  100. X     while (*argv != '\x0a')
  101. X          {
  102. X           *myptr = *argv;
  103. X            myptr++;
  104. X            argv++;
  105. X          }
  106. X     myptr = MyPath;
  107. X    }
  108. X
  109. X    if (!getdfs (myptr,&info))            /* getdfs() - AMIGA function */
  110. X     {
  111. X      register long bytes = (long) (info.id_NumBlocks - info.id_NumBlocksUsed) * info.id_BytesPerBlock;
  112. X
  113. X      Printf("%s ",myptr);
  114. X
  115. X      if (bytes > Mb)
  116. X      {
  117. X       register long Mbytes =  bytes / Mb;
  118. X       register long Kbytes = (bytes % Mb) / 100000; 
  119. X       Printf("%ld.%ld Mb",Mbytes,Kbytes);
  120. X      }
  121. X      else Printf("%ld bytes",bytes);
  122. X
  123. X      Printf(" free.\n");
  124. X      return;                              /* normal exit */
  125. X     }
  126. X
  127. Xerror:
  128. X
  129. X     Printf("\n\2331;33m Bytes\2330m\2331;31m Version 1.10 Public Domain 1990 /PBM/ Per Bergehed.\2330m\n");
  130. X     Printf(" - to contact me send e-mail to: d0pbm@dtek.chalmers.se -\n");
  131. X     Printf("\n Syntax:\2331;33m Bytes\2330m [DRIVE:]\n\n");
  132. X
  133. Xreturn;                                    /* error exit! */
  134. X}
  135. X//*-------------------------------------------------------------------------*/
  136. X
  137. X
  138. X
  139. END_OF_FILE
  140. if test 3040 -ne `wc -c <'bytes.c'`; then
  141.     echo shar: \"'bytes.c'\" unpacked with wrong size!
  142. fi
  143. # end of 'bytes.c'
  144. fi
  145. echo shar: End of archive 1 \(of 1\).
  146. cp /dev/null ark1isdone
  147. MISSING=""
  148. for I in 1 ; do
  149.     if test ! -f ark${I}isdone ; then
  150.     MISSING="${MISSING} ${I}"
  151.     fi
  152. done
  153. if test "${MISSING}" = "" ; then
  154.     echo You have the archive.
  155.     rm -f ark[1-9]isdone
  156. else
  157.     echo You still need to unpack the following archives:
  158.     echo "        " ${MISSING}
  159. fi
  160. ##  End of shell archive.
  161. exit 0
  162. -- 
  163. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  164. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  165. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  166.